package cn.glc.daily.life.config.swagger;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @author simon
 * @date 2020/9/28 17:35
 * @copyright:
 * @modifier
 * @motto a no talent, people who have to study hard
 */
@Configuration
@EnableSwagger2
public class SwaggerConfig {

    @Bean
    public Docket api() {
        return new Docket(DocumentationType.SWAGGER_2)
                .groupName("v1")
                .apiInfo(apiInfo())
                .enable(true)
                .select()
                .apis(RequestHandlerSelectors.basePackage("cn.glc.daily.life.web.controller"))
                .paths(path -> path.indexOf("/error/throw") == -1)
                .build();
    }


    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("dailyLife Server API")
                .contact("simon")
                .version("v1.0")
                .build();
    }

}
